<template>
  <div>
    <ReviewType
      @e-courseType="handleClick"
      :flowRunTaskVOList="flowRunTaskVOList"
      type="audit"
    />
    <el-tabs v-model="activeName" type="card" @tab-click="handleClick()">
      <el-tab-pane label="待审信息" name="1"></el-tab-pane>
      <el-tab-pane label="已审信息" name="2"></el-tab-pane>
    </el-tabs>
    <!-- 课程元素库审核 -->
    <UnReview v-if="courseType <= 6" :tableData="tableData" />
    <!-- 账号审核 -->
    <UnReviewAccont v-if="courseType == 11" :tableData="tableData" />
    <!-- 思政元素审核 -->
    <UnReviewIdeo v-if="courseType == 21" :tableData="tableData" />
    <!-- 分页 -->
    <Pagination
      v-show="parseInt(pageObj.count) > 0"
      :total="parseInt(pageObj.count)"
      @change="getList"
      :page.sync="listQuery.page"
      :limit.sync="listQuery.limit"
    />
    <!-- 评审弹窗 -->
    <ReviewDialog />
    <!-- 评审记录 -->
    <ReviewHistory />
    <!-- 推送专家 -->
    <PushSpecialist />
    <!-- 专家建议 -->
    <!-- <ExpertAdvice /> -->
    <!-- 查看审核流程 -->
    <AuditFlow />
  </div>
</template>
<script>
import { flowRunTaskQuery } from '@/api/admin/audit/flowApi.js'
import { flowHisTaskQuery } from '@/api/admin/audit/flowApi.js'
import Bus from '@/utils/bus.js'
export default {
  components: {
    ReviewDialog: () => import('./ReviewDialog.vue'),
    ReviewType: () => import('./ReviewType.vue'),
    UnReview: () => import('./UnReview.vue'),
    UnReviewIdeo: () => import('./UnReviewIdeo.vue'),
    UnReviewAccont: () => import('./UnReviewAccont.vue'),
    ReviewHistory: () => import('./ReviewHistory.vue'),
    PushSpecialist: () => import('./PushSpecialist.vue'),
    // ExpertAdvice: () => import("./ExpertAdvice.vue"),
    AuditFlow: () => import('./AuditFlow.vue'),
  },
  data() {
    return {
      activeName: '1',
      courseType: 1,
      listQuery: {
        page: 1,
        limit: 10,
        approverId: this.$store.getters.userId,
        courseType: 1,
      },
      tableData: [],
      pageObj: {},
      flowRunTaskVOList: [],
    }
  },
  mounted() {
    this.getList()
    Bus.$on('flowRunTaskList', (v) => {
      this.getList()
    })
  },
  beforeDestroy() {
    Bus.$off('flowRunTaskList')
  },
  methods: {
    getList() {
      if (this.activeName == 1) {
        flowRunTaskQuery(this.listQuery).then((res) => {
          this.tableData = res.data.data[0].flowRunTaskList
          this.flowRunTaskVOList = res.data.data[0].flowRunTaskVOList
          this.pageObj = res.data
        })
      } else {
        flowHisTaskQuery(this.listQuery).then((res) => {
          this.tableData = res.data.data
          this.pageObj = res.data
        })
      }
    },
    handleClick(v) {
      if (v) {
        this.courseType = v
        this.listQuery.courseType = v
        this.activeName = '1'
      }
      this.tableData = []
      this.pageObj = {}
      this.getList()
    },
  },
}
</script>